<layout name="Layout/layout" />

<div id="wrapper">
    <div class="col-md-2">
        <include file="Layout:left-menubar" />
    </div>

    <div class="col-md-10">
    <!-- Page Content -->
    <div id="page-content-wrapper">
        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">
                    <h1>我的资料</h1>
                    <form class="form-horizontal" action="{:U('Home/Index/infoHandle')}" method="post">
                        <div class="panel panel-default">
                            <div class="panel-body">
                                <fieldset disabled>
                                    <div class="form-group">
                                        <label for="idcardtype" class="col-sm-2 control-label">证件类型</label>
                                        <div class="col-sm-10">
                                            <select id="idcardtype" class="form-control">
                                                <option>身份证</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label for="idcardnumber" class="col-sm-2 control-label">证件号码</label>
                                        <div class="col-sm-10">
                                        <input type="text" class="form-control" id="idcardnumber" placeholder="请输入您的证件号码" value="{$accountinfo['username']}">
                                        </div>
                                    </div>
                                </fieldset>
                            </div>
                        </div>
                        <div class="panel panel-danger">
                            <div class="panel-heading">必填项</div>
                            <div class="panel-body">
                                <div class="form-group">
                                    <label for="provinces" class="col-sm-2 control-label">高考省份</label>
                                    <div class="col-sm-10">
                                        <select name="province" id="provinces" class="form-control">
                                            <foreach name="provinces" item="v">
                                                <option value="{$v['code']}">{$v['name']}</option>
                                            </foreach>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="stunumber" class="col-sm-2 control-label">考生号</label>
                                    <div class="col-sm-10">
                                    <input name="stunumber" type="text" class="form-control" id="stunumber" placeholder="请输入您的考生号" value="{$now['stunumber']}" required>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="restunumber" class="col-sm-2 control-label">确认考生号</label>
                                    <div class="col-sm-10">
                                    <input name="restunumber" type="text" class="form-control" id="restunumber" placeholder="请再次输入您的考生号" value="{$now['stunumber']}" required>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="address" class="col-sm-2 control-label">通讯地址</label>
                                    <div class="col-sm-10">
                                    <input name="address" type="text" class="form-control" id="address" placeholder="请输入您的通讯地址" value="{$now['address']}" required>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="zipcode" class="col-sm-2 control-label">邮政编码</label>
                                    <div class="col-sm-10">
                                    <input name="zipcode" type="text" class="form-control" id="zipcode" placeholder="请输入您的邮政编码" value="{$now['zipcode']}" required>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="telofparent" class="col-sm-2 control-label">家长手机</label>
                                    <div class="col-sm-10">
                                    <input name="telofparent" type="telephone" class="form-control" id="telofparent" placeholder="请输入您家长的手机,如要填写多个用,隔开" value="{$now['telofparent']}" required>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="telofyou" class="col-sm-2 control-label">本人手机</label>
                                    <div class="col-sm-10">
                                    <input name="tel" type="telephone" class="form-control" id="telofyou" placeholder="请输入您的手机" value="{$now['tel']}" required>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="panel panel-success">
                            <div class="panel-heading">选填项</div>
                            <div class="panel-body">
                                <div class="form-group" >
                                    <label for="name" class="col-sm-2 control-label">姓名</label>
                                    <div class="col-sm-10">
                                    <input type="text" class="form-control" id="name" placeholder="请输入您的姓名" value="{$accountinfo['name']}" disabled>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="optionsRadios1" class="col-sm-2 control-label">性别</label>
                                    <div class="col-sm-10">
                                        <div class="radio">
                                            <label>
                                                <input type="radio" name="sex" id="optionsRadios1" value="1">
                                                男
                                            </label>
                                            <label>
                                                <input type="radio" name="sex" id="optionsRadios2" value="0">
                                                女
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="birthday" class="col-sm-2 control-label">生日</label>
                                    <div class="col-sm-10">
                                        <input name="birthday" type="text" class="form-control birthday" placeholder="请输入生日，格式为yyyy-mm-dd,如：1995-08-26" value="{$now['birthday']}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="politicsstatus" class="col-sm-2 control-label">政治面貌</label>
                                    <div class="col-sm-10">
                                        <select name="politics" id="politicsstatus" class="form-control">
                                            <foreach name="politicsstatus" item="v">
                                                <option value="{$v['code']}">{$v['name']}</option>
                                            </foreach>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="freshoptionsRadios1" class="col-sm-2 control-label">应往届</label>
                                    <div class="col-sm-10">
                                        <div class="radio">
                                            <label>
                                                <input type="radio" name="isfresh" id="freshoptionsRadios1" value="1">
                                                应届
                                            </label>
                                            <label>
                                                <input type="radio" name="isfresh" id="freshoptionsRadios2" value="0">
                                                往届
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="scienceoptionsRadios1" class="col-sm-2 control-label">文理科</label>
                                    <div class="col-sm-10">
                                        <div class="radio">
                                            <label>
                                                <input type="radio" name="science" id="scienceoptionsRadios1" value="1">
                                                理科
                                            </label>
                                            <label>
                                                <input type="radio" name="science" id="scienceoptionsRadios2" value="0">
                                                文科
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="nations" class="col-sm-2 control-label">民族</label>
                                    <div class="col-sm-10">
                                        <select name="nation" id="nations" class="form-control">
                                            <foreach name="nations" item="v">
                                                <option value="{$v['code']}">{$v['name']}</option>
                                            </foreach>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="school" class="col-sm-2 control-label">所在学校</label>
                                    <div class="col-sm-10">
                                    <input name="school" type="text" class="form-control" id="school" placeholder="请输入您的所在学校" value="{$now['school']}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="qqofyou" class="col-sm-2 control-label">本人qq</label>
                                    <div class="col-sm-10">
                                    <input name="qq" type="text" class="form-control" id="qqofyou" placeholder="请输入您的qq" value="{$now['qq']}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-sm-offset-2 col-sm-10">
                                    <button id="savebtn" type="submit" class="btn btn-default">保存</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- /#page-content-wrapper -->
    </div>
</div>
<!-- /#wrapper -->
<script>
window.onload = function(){
    $('#savebtn').click(function(){
        // 校验考生号
        if(!/^\d{9,14}$/.test($('#stunumber').val())){
            alert($('#stunumber').val() + ' 不是一个合法的考生号，请确保你输入的考生号是9-14为的数字');
            return false;
        }
        // 校验考生号两次输入是否一致
        if($('#stunumber').val() != $('#restunumber').val()){
            alert('两次输入的考生号不一致');
            return false;
        }
        // 校验邮政编码是否合法
        if(!/^\d{6}$/.test($('#zipcode').val())){
            alert('你输入的邮政编码有误，请核对后重新保存');
            return false;
        }
        if(!/^\d{11}$/.test($('#telofyou').val())){
            alert('你输入的电话号码有误，请核对后重新保存');
            return false;
        }
        return true;
    });
    $('#provinces').val({$now['province']});
    var sex = {$now['sex']};
    if(sex == 1){
        $('input[name=sex]').eq(0).attr('checked', 'checked');
    }else{
        $('input[name=sex]').eq(1).attr('checked', 'checked');
    }
    var isfresh = <?php echo ($now['isfresh']=="") ? 1 : $now['isfresh']; ?>;
    var science = <?php echo ($now['is_science_focus']=="") ? 1 : $now['is_science_focus']; ?>;
    if(isfresh == 1){
        $('input[name=isfresh]').eq(0).attr('checked', 'checked');
    }else{
        $('input[name=isfresh]').eq(1).attr('checked', 'checked');
    }
    if(science == 1){
        $('input[name=science]').eq(0).attr('checked', 'checked');
    }else{
        $('input[name=science]').eq(1).attr('checked', 'checked');
    }
    $('#politicsstatus').val({$now['politics']});
    $('#nations').val({$now['nation']});
}

</script>
